package middle;

import java.util.Arrays;

public class Solution_274 {

    public int hIndex(int[] citations) {
        Arrays.sort(citations);
        for (int i = citations.length - 1; i >= 0; i--) {
            if (citations[i] < citations.length - i) {
                return citations.length - i - 1;
            }
        }
        return citations.length;
    }

    public static void main(String[] args) {
        Solution_274 model = new Solution_274();
        System.out.println(model.hIndex(new int[]{3,0,6,1,5}));
        System.out.println(model.hIndex(new int[]{1,3,1}));
    }
}
